#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "newprojectargs.h"
#include "newproject.h"
#include <QtGui>
#include <QtCore/QMap>
#include "../Controller/centralController.h"
#include "../Tools/qtoolgraphicsscene.h"
#include "../Tools/qmytool.h"
#include "../Tools/qrecttool.h"
#include "../Tools/q_selected_edit_tool.h"
#include "../Tools/qcurvetool.h"
#include "../Tools/qellipsetool.h"
#include "../Tools/qpicturetool.h"
#include "../Tools/qwordtool.h"
#include "../Tools/qmoviecliptool.h"
#include"../Tools/qpenciltool.h"
#include"../Tools/qgradienttool.h"
#include<qvariant.h>
namespace Ui {
class MainWindow;
}
enum buttonState
{
	rectclick,
	ellipseclick,
	curveclick,
	selectclick,
	pictureclick,
	wordclick,
	movieclipclick,
	pencilclick,
	gradientclick,
	noclick
};
enum cbScene
{
	select,
	Circle,
	Curve,
	Brush,
	Fill,
	Rectb,
	Gradient,
	Text,
	Pic,
	Node
};
class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

	QTreeWidgetItem* root;
	centralController* controller;
	void addTools(QToolGraphicsScene* s);
	buttonState buttonstate;
	bool ifAddKey;
	bool ifEdit;
	Ease::EaseType transToEase(QString );
	propertyType stringToProperty(QString);
    QWidget * currentWidget();
    QMap<QWidget*, QString> tabToNode;
    QMap<QString, QWidget*> nodeToTab;

    void crateNewTab(QGraphicsScene *, QVector<int>);

    int projectNum; 
    QWidget* returnTab(QString);
    QVector<int> returnNode(QWidget*);

    void createTextTools();
    void createToolsButtonGroup();
    void handleFontChange();
    void DFS(int node, QTreeWidgetItem *item);
	void freshSccreen();
public slots:
    void createNewProject(newProjectArgs args);

    void getWidget(QWidget*);

    void getPath(QString, QWidget*);

	void addANewTab(QToolGraphicsScene*,QVector<int>);
	void getCurrentTabPath(QString&);
	void showProperty(int );

	void showMenu(const QPoint&);
	void refreshTreeView(nodePath );
	void clearProperty();
	void refreshProperty(int);
	void openNewProject();
private slots:

	void currentFontSizeChanged(int);
	void on_actionAddKeyframe_triggered();
	void on_actionDeleteKeyframe_triggered();
	void on_actionDelete_triggered();
	void on_actionUndo_triggered();
	void on_actionRedo_triggered();
    void on_actionNew_triggered();
	void on_actionUp_triggered();
	void on_actionDown_triggered();

    void on_actionExit_triggered();

    void on_tabWidget_tabCloseRequested(int index);
	
	void on_tabWidget_currentChanged(QWidget *arg);

	void on_treeWidget_itemChanged ( QTreeWidgetItem * item, int column );

//<<<<<<< .mine
    void on_buttonRect_clicked();
//=======
    void on_treeViewWidget_itemClicked(QTreeWidgetItem *item, int column);
//>>>>>>> .r268

//<<<<<<< .mine
    void on_buttonSelect_clicked();
//=======
    void toolsButtonGroupClicked(int id);
//>>>>>>> .r268

//<<<<<<< .mine
    void on_buttonCircle_clicked();
//=======
    int on_timeLine_valueChanged(int value);
//>>>>>>> .r268

//<<<<<<< .mine
    void on_buttonCurve_clicked();
//=======
    void on_actionExport_triggered();
//>>>>>>> .r268

	void on_actionSave_triggered();
	void on_actionOpen_triggered();
    //void on_buttonRect_clicked();

    //void on_buttonSelect_clicked();

    //void on_buttonCurve_clicked();

    //void on_buttonCircle_clicked();

    void on_buttonText_clicked();

    void on_buttonBrush_clicked();

    void on_buttonGradient_clicked();

    void on_buttonFill_clicked();

    void on_buttonPic_clicked();

    void on_buttonNode_clicked();

	void on_pushButtonColorFront_clicked();

	void on_pushButtonColorBack_clicked();

	void currentFontChanged(QFont );
	void currentfonteverychange();
private:
    Ui::MainWindow *ui;

    QComboBox *fontSizeCombo;
    QFontComboBox *fontCombo;
    QAction *boldAction;
    QAction *underlineAction;
    QAction *italicAction;

	QColor colorFront;
	QColor colorBack;

    class QtDoublePropertyManager *doubleManager;
    class QtStringPropertyManager *stringManager;
    class QtColorPropertyManager *colorManager;
    class QtFontPropertyManager *fontManager;
    class QtPointPropertyManager *pointManager;
    class QtSizeFPropertyManager *sizeManager;
	class QtBoolPropertyManager *boolManager;
	class QtGroupPropertyManager *groupManager;

    QButtonGroup *toolsButtonGroup;

    class QtTreePropertyBrowser *propertyEditor;

	



    int movieTime;
};

#endif // MAINWINDOW_H
